package com.cn.admin.vo;


import com.alibaba.fastjson.annotation.JSONField;
import org.apache.poi.ss.formula.functions.T;

public class ResponseObject<T> {

    private String code;
    private String desc;
    private T data;

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public static <T> ResponseObject<T> newInstance(String code, String desc, T data) {
        ResponseObject responseObject=new ResponseObject();
        responseObject.setCode(code);
        responseObject.setDesc(desc);
        responseObject.setData(data);
        return responseObject;
    }

    public static <T>  ResponseObject<T> success(T data) {
        ResponseObject responseObject=new ResponseObject();
        responseObject.setCode("20000");
        responseObject.setDesc("成功");
        responseObject.setData(data);
        return responseObject;
    }

    public static <T>  ResponseObject<T> fail(Integer code,T data) {
        ResponseObject responseObject=new ResponseObject();
        responseObject.setCode(code+"");
        responseObject.setDesc("失败");
        responseObject.setData(data);
        return responseObject;
    }

}
